<template>
  <div class="job-list-content">
    <div class="job-box job-list" v-for="(item,index) in jobList" :key="index">
      <div class="job-list-top" @click="doDetails(item.jobId,item.companyId)">
        <div class="job-list-top-left">
          <div>
            <span class="todetail">{{item.name ? item.name : '---'}}</span>

            <span class="left-money">
              <span style="color:#999;" v-if="item.tax == 0">税前&nbsp;</span>
              <span style="color:#999;" v-if="item.tax == 1">税后&nbsp;</span>
              {{item.salaryPerMonthLow ? item.salaryPerMonthLow :'---'}}-{{item.salaryPerMonthHigh ? item.salaryPerMonthHigh +'W' : '---'}}
              <span
                style="color:#999;font-size:12px;"
              >/{{item.salaryCount ? item.salaryCount +'年' : '---'}}</span>
            </span>
          </div>

          <div class="job-list-sub-text">
            <span>{{item.city ? item.city : '---'}}</span>
            <span>|</span>
            <span>{{item.workTime ? item.workTime : '经验不限'}}</span>
            <span>|</span>
            <span>{{item.eduReq ? item.eduReq : '---'}}</span>
            <span>|</span>
            <span>{{item.licenseReq ? item.licenseReq : '---'}}</span>
            <span>|</span>
            <span>{{item.feedbackTime ? item.feedbackTime + '反馈' : '---'}}</span>
          </div>
        </div>

        <div class="job-list-top-right">
          <div>{{item.companyName ? item.companyName : '---'}}</div>
          <div class="job-list-sub-text">
            <span>{{item.companySize ? item.companySize : '---'}}</span>
            <span>|</span>
            <span>{{item.companyNature ? item.companyNature : '---'}}</span>
          </div>
        </div>
      </div>
      <div class="job-list-bottom">
        <div class="job-list-bottom-bonus">
          自荐奖金：
          {{item.bonus ? item.bonus + 'K' : '---'}}
        </div>
        <el-button
          v-if="item.report == 10"
          class="oneself-button"
          @click.stop="recommendOneself(item.jobId,item.companyId,item)"
        >自荐</el-button>
        <el-button v-else class="primary-button gary-button" @click.stop="selfed" disabled>已自荐</el-button>
      </div>
    </div>
    <el-dialog style="margin-top: 15vh;" :visible.sync="loginDialog" title="提示">
      <all-dialog
        :job-id="jobId"
        :jrr-id="jrrId"
        :job-name="jobName"
        :company-name="companyName"
        :platformUserId="platformUserId"
        :type="type"
        v-model="loginDialog"
      ></all-dialog>
    </el-dialog>
  </div>
</template>

<script>
import allDialog from '../../components/all-dialog'
export default {
  props: ['jobList'],
  data() {
    return {
      resumeIntegrity: {},
      loginDialog: false,
      type: 0,
      talentInfo: {},
      platformUserId: '',
      jrrId: '',
      jobName: '',
      companyName: '',
      jobId: ''
    }
  },
  methods: {
    doDetails(job, company) {
      this.$router.push({
        path: '/job/details',
        query: { jobId: job, companyId: company }
      })
    },
    recommendOneself(jobId, companyId, item) {
      this.companyName = item.companyName
      this.jobName = item.name
      this.jobId = item.jobId
      let params = {
        jobId: jobId,
        companyId: companyId
      }
      if (this.resumeIntegrity.resumeIntegrity < 90) {
        this.loginDialog = true
        this.type = 1
        return
      } else if (
        this.resumeIntegrity.resumeIntegrity == 90 &&
        this.resumeIntegrity.onlineResume != 0
      ) {
        this.loginDialog = true
        this.type = 1
        return
      }

      _g.apiPost('/talent/selectTalentState.do', {}).then(res => {
        if (res.status == 0) {
          if (res.data == 2) {
            //3执业信息异常
            this.loginDialog = true
            this.type = 3
            this.flag = false
            this.platformUserId = item.platformUserId
            return
          } else if (res.data == 0) {
            //4执业信息待审核
            this.loginDialog = true
            this.type = 4
            this.flag = false
            this.platformUserId = item.platformUserId
            return
          }

          //0 登录时简历为完善 1自荐时简历未完善 2简历投递中 3执业信息异常 4执业信息待审核
          _g.apiPost('/talent/recommendSelfResume.do', params).then(res => {
            if (res.status == 0) {
              this.loginDialog = true
              this.type = 2
              this.platformUserId = res.data['platformUserId']
              this.jrrId = res.data['jrrId']
              item.report = 11
            }
            _g.toMessage(res)
          })
        }
      })
      //this.$emit('on-pitch', true)
    },
    selfed() {
      console.log('已自荐')
    }
  },
  components: { allDialog },
  created() {
    let resumeIntegrity = localStorage.getItem('resumeIntegrity');
    if (resumeIntegrity != undefined) {
      this.resumeIntegrity = JSON.parse(localStorage.getItem('resumeIntegrity'))
    }
    this.talentInfo = JSON.parse(localStorage.getItem(localSaved.userInfo))
  }
}
</script>

<style lang="scss" scoped>
.todetail {
  cursor: pointer;
  &:hover {
    color: #f09338;
  }
}
</style>
